#pragma once

#include <QTabWidget>
#include <QString>
#include "ui_VCenterTabWidget.h"
#include "VBackgroundSystem.h"
#include "VScintillaEx.h"
#include "VWords.h"
#include "VTabWidget.h"
#include <QStringList>

class VCenterTabWidget : public VTabWidget
{
	Q_OBJECT

public:
	VCenterTabWidget(QWidget* parent, VBackgroundSystem* bsystem);
	~VCenterTabWidget();
	void open_file(QString path);
	bool is_open_file(QString path);
	bool change_to_path(QString path);
	int get_index(QString path);
	void scintilla_connect(VScintillaEx* scintilla);
	void init_connect();
	void advance();
	void retreat();
	void saveAll();
	void undo();
	void redo();
	void cut();
	void copy();
	void paste();
	void comment();
	void uncomment();
	void backTab();
	void Tab();
	bool close_paths(QStringList paths);
	bool close_query();

signals:
	void signal_scintilla_update_info(QString path, int line, int pos, int lines);

public slots:
	void slot_jump(QString path, int line_number);

private:
	struct NavigationInfo
	{
		int line;
		int pos;
		QString path;
	};
	VBackgroundSystem* _bsystem;
	QList<NavigationInfo> _navigation_list;
	int _navigation_index = -1;
	QString get_calltip_icon(int type);
	QString calltip_item_text(VWords* p_word);
	bool jump_to(QString path, int line, int pos = -1, bool append = true);
	void init_call_tip_widget();
	void append_navigation(QString path, int line, int pos);

private slots:
	void on_tabCloseRequested(int index);
	void onCurrentWidgetChanged(QWidget *w);
	void slot_input_word_transfer(VWords* word);
	void slot_hide_tip(int mode);
	void slot_append_navigation(QString path, int line, int pos);
	void slot_show_input_calltip(QList<VWords*> list);
	void slot_show_function_parameter_calltip(QString text, int pos);
	void slot_show_mouse_hover_calltip(QString text, int pos);
	void slot_set_title(QString path, QString title);
	void slot_scintilla_update_info(QString path, int line, int pos, int lines);
};
